<template>
	<view class="container" >
		<view class="status_bar">
			<view style="margin-left: 3%;" @tap="goBack()"><u-icon name="arrow-leftward" size='24' /></u-icon></view>
			<view style="font-weight: bold;">聊天成员</view>
			<view style="margin-right: 30upx;color: #d54827;" @tap="saveShow=true">完成</view>
		</view>
		<view class="wrapper">
			<view class="search-box">
				<u-search placeholder="请输入您想搜索的内容" v-model="keyword" :showAction="false" searchIconColor="#373737"
					placeholderColor="#bcbcbc"></u-search>
			</view>
			<view class="img-value">
				<view v-for="(item,index) in checkListValue" :key="index" class="img-value1">
					<u--image :showLoading="true" :src="item.url" width="80upx" height="80upx"
						radius="10upx"></u--image>
					<view class="delete-btn" @tap="handleDelete(item.id)">
						<u-icon name="minus-circle-fill" size=22 color="#d54827"></u-icon>
					</view>
				</view>
			</view>
			<view class="uni-list">
				<checkbox-group @change="checkboxChange">
					<label class="uni-list-cell" v-for="(item,index) in checkboxList1" :key="index">
						<view>
							<checkbox :value="item" :checked="item.checked" />
						</view>
						<view style="border-radius: 30upx;margin-left: 10upx;" v-if="item.url">
							<u--image :showLoading="true" :src="item.url" width="80upx" height="80upx"
								radius="10upx"></u--image>
						</view>
						<view v-else class="name-img">多</view>
						<view style="margin-left: 20upx;position: relative;">{{item.name}}</view>
					</label>
				</checkbox-group>
			</view>
			<!-- 保存弹框-->
			<u-popup :show="saveShow" @close="recordsClose" mode="center" :round="20">
				<view class="clear-record-box">
					<view class="clear-record-box-title">确定将勾选用户设置为管理员</view>
					<view class="clear-record-box-btn">
						<view class="clear-record-box-btn-left" @tap="recordsClose()">取消</view>
						<view class="clear-record-box-btn-right" @tap="recordsConFirm()">确认</view>
					</view>
				</view>
			</u-popup>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				startX: 0, // 触摸开始的X坐标
				endX: 0, // 触摸结束的X坐标
				threshold: 50, // 设置滑动多少距离后触发返回
				value1: '哈哈哈@坐席',
				textShow: true,
				groupList: [{
					groupName: 'hhh'
				}, {
					groupName: 'xxx'
				}],
				checkboxValue1: [],
				keyword: '',
				// 基本案列数据
				checkboxList1: [{
						name: '哈哈哈',
						url: '../../static/img/face.png',
						time: '11-12 16:02',
						disabled: false,
						id: 1
					},
					{
						name: '嘻嘻嘻',
						time: '11-12 16:02',
						disabled: false,
						id: 2
					},
					{
						name: '哈哈哈',
						url: '../../static/img/face.png',
						time: '11-12 16:02',
						disabled: false,
						id: 3
					},
				],
				checkListValue: [],
				saveShow: false
			}
		},
		onLoad(props) {
			// console.log(props.type, "props")
			// this.type = props.type
			//	this.getDetail()
		},
		methods: {
			goBack() {
				uni.navigateBack({
					delta: 1
				});
			},
			
			
			checkboxChange(e) {
				this.checkListValue = e.detail.value

			},
			//删除
			handleDelete(id) {
				// let checkListValue1 = this.checkListValue.filter(item => item.id == id);
				// if (checkListValue1) {
				// 	checkListValue1.checked = false
				// }
				// console.log(this.checkListValue,111)
				this.checkListValue = this.checkListValue.filter(item => item.id !== id);
				// let checkListValue1 = this.checkListValue.filter(item => item.id == id);
			},
			//弹框
			recordsClose() {
				this.saveShow = false
			},
			recordsConFirm() {
				this.saveShow = false
			},
			//全选
			selectAll() {
				this.checkboxList1 = this.checkboxList1.map((item) => {
					return {
						checked: true,
						...item
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 100%;
		height: 100%;
	}

	.status_bar {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 50upx;
	}

	.status_bar,
	.head {
		background-color: #fff;
		height: 160upx;

		.face {
			width: 160upx;
			height: 160upx;
			border-radius: 10upx;
		}

		.info-name {
			font-size: 40upx;
			font-weight: bold;
		}

		.info-num {
			padding: 2upx 30upx;
			background: #f0f4f7;
			border-radius: 30upx;
			margin-top: 21upx;
		}

		.copybtns {
			color: #4457a4;
			margin-top: 21upx;
		}
	}

	.wrapper {
		width: 92%;
		margin-left: 4%;

		// .select-box {
		// 	margin: 10upx 1% 0 2%;
		// 	display: flex;
		// 	justify-content: space-around;
		// 	align-items: center;
		// }
		.uni-list-cell {
			justify-content: flex-start;
			display: flex;
			align-items: center;
			padding: 30upx;
			margin-top: 30upx;
		}

		.name-img {
			width: 80upx;
			height: 80upx;
			border-radius: 10upx;
			background: #d54827;
			font-size: 36upx;
			text-align: center;
			line-height: 80upx;
			color: #fff;
			margin-left: 10upx;
		}

		.img-value {
			border-radius: 30upx;
			margin-left: 10upx;
			display: flex;
			margin-top: 30upx;

			.img-value1 {
				margin-left: 30upx;
				position: relative;
			}

			.delete-btn {
				position: absolute;
				top: -16%;
				left: 76%;
			}
		}
	}




	.clear-record-box {
		border-radius: 30upx;
		padding: 30upx;

		.clear-record-box-title {
			padding: 10upx 20upx;
			font-size: 40upx;
		}

		.clear-record-box-btn {
			display: flex;
			margin-left: 150upx;
			margin-top: 60upx;
		}

		.clear-record-box-btn-left {
			padding: 10upx 30upx;
		}

		.clear-record-box-btn-right {
			background: #000;
			color: #fff;
			padding: 10upx 40upx;
			margin-left: 30upx;
		}
	}
</style>